Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

effector-debounce

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

effector-debounce

[![npm bundle size](https://img.shields.io/bundlephobia/min/effector-debounce)](https://bundlephobia.com/result?p=effector-debounce)

  • 1.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
15
decreased by-6.25%
Maintainers
1
Weekly downloads
 
Created
Source

Effector Debounce

npm bundle size

https://codesandbox.io/s/effector-throttle-debounce-w32tk

Installation

npm install --save effector effector-debounce

# or

yarn add effector effector-debounce

Usage

Create event that should be debounced:

import { createEvent } from 'effector';

const someHappened = createEvent<number>();

Create debounced event from it:

import { createDebounce } from 'effector-debounce';

const DEBOUNCE_TIMEOUT_IN_MS = 200;

const debounced = createDebounce(someHappened, DEBOUNCE_TIMEOUT_IN_MS);

To test that original event is correctly debounced you can add watcher:

someHappened.watch((payload) => {
  console.info('someHappened now', payload);
});

debounced(1);
debounced(2);
debounced(3);
debounced(4);

// someHappened now 4

Also you can use Effect and Store as trigger. createDebounce always returns Event:

const event = createEvent<number>();
const debouncedEvent: Event<number> = createDebounce(event, 100);

const fx = createEffect<number, void>();
const debouncedEffect: Event<number> = createDebounce(fx, 100);

const $store = createStore<number>(0);
const debouncedStore: Event<number> = createDebounce($store, 100);

Change name

const trigger = createEvent();
const debounced = createDebounce(trigger, 100);

// Now debounced var has `triggerDebounceTick` name

To change name:

const trigger = createEvent();
const debounced = createDebounce(trigger, 100, { name: 'Hello' });

// Now debounced var has `HelloDebounceTick` name

FAQs

Package last updated on 24 Mar 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc